<!DOCTYPE html>
<html lang="en" class="svg no-js">
<head>
    <meta charset="utf-8" />
    <!--[if IE ]>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <![endif]-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="Language" content="en">

    <title>MySQL :: MySQL 8.0 Reference Manual :: 12.11 XML Functions</title>
    <link rel="stylesheet" media="all" href="css/main-20190125.min.css" />
            <link rel="stylesheet" media="all" href="css/docs-20190125.min.css" />
    
    
    <link rel="stylesheet" media="print" href="css/print-20190125.min.css" />

    
    
    
    
            <link rel="contents" href="index.html" title="MySQL 8.0 Reference Manual" />
<link rel="start" href="index.html" title="MySQL 8.0 Reference Manual" />
<link rel="prev" href="cast-functions.html" title="12.10 Cast Functions and Operators" />
<link rel="next" href="bit-functions.html?ff=nopfpls" title="12.12 Bit Functions and Operators" />
<link rel="up" href="functions.html" title="12 Functions and Operators" />

    
    <link rel="shortcut icon" href="favicon.ico" />
    <script>(function(H){ H.className=H.className.replace(/\bno-js\b/,'js') })(document.documentElement)</script>
    <script src="js/site-20181120.min.js"></script>

    
    
    
    <!--[if lt IE 9]>
        <script src="https://labs.mysql.com/common/js/polyfills/html5shiv-printshiv-3.7.2.min.js"></script>
        <script src="https://labs.mysql.com/common/js/polyfills/respond-1.4.2.min.js"></script>
    <![endif]-->
        <!--[if IE 9]>
        <style>#docs-sidebar-toc { box-sizing: content-box; }</style>
    <![endif]-->
    </head>

<body class="no-sidebar full-page dev">
<div class="page-wrapper">
    <header>

                        <a href="https://dev.mysql.com/" aria-label="Home" title="MySQL" id="l1-home-link"></a>
        
        <div id="l1-nav-container">
            <div id="l1-line1">
                <div id="l1-auth-links">
                    <a href="https://www.mysql.com/about/contact/"><b>Contact MySQL</b></a>
                    <span id="l1-contact-separator">&nbsp;|&nbsp;</span>
                    <span id="l1-contact-separator-br"><br /></span>
                                             <a href="https://dev.mysql.com/auth/login/?dest=https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F8.0%2Fen%2Fxml-functions.html">Login</a> &nbsp;|&nbsp;
                         <a href="https://dev.mysql.com/auth/register/">Register</a>
                                    </div>
                <div id="l1-lhs">
                    <div id="l1-slogan">
                        The world's most popular open source database
                    </div>
                    <div id="l1-search-box">
                        <form id="l1-search-form" method="get" action="https://www.oracle.com/search/results">
                        <input type="hidden" name="cat" value="mysql" />
                        <input type="hidden" name="Ntk" value="SI-ALL5" />
                        <input id="l1-search-input" type="search" class="icon-search" placeholder="Search" aria-label="Search" name="Ntt" />
                        </form>
                    </div>
                </div>
            </div>
            <div id="l1-line2">
                <div class="social-icons">
                    <a aria-label="Join us on Facebook" title="Join us on Facebook" href="http://www.facebook.com/mysql"><span class="icon-facebook"></span></a>
                    <a aria-label="Follow us on Twitter" title="Follow us on Twitter" href="https://twitter.com/mysql"><span class="icon-twitter"></span></a>
                    <a aria-label="Follow us on LinkedIn" title="Follow us on LinkedIn" href="https://www.linkedin.com/company/mysql"><span class="icon-linkedin"></span></a>
                    <a aria-label="Visit our YouTube channel" title="Visit our YouTube channel" href="http://www.youtube.com/mysqlchannel"><span class="icon-youtube"></span></a>
                </div>
                <ul id="l1-nav">
                    <li>
                        <a href="https://www.mysql.com/"><!-- <span class="icon-sakila"></span>  -->MySQL.com</a>
                    </li><li>
                        <a href="https://www.mysql.com/downloads/"><!-- <span class="icon-download-thin"></span>  -->Downloads</a>
                    </li><li class="active">
                        <a href="/doc/"><!-- <span class="icon-books"></span>  -->Documentation</a>
                    </li><li>
                        <a href="/"><!-- <span class="icon-code"></span>  -->Developer Zone</a>
                    </li>                </ul>
            </div>
        </div>
        <div id="sub-header">
            <div id="l2-nav-container">
                <div id="l2-nav-toggle">
                    <span class="icon-three-bars"></span>
                </div>
                                                                                        <a class="button nav-button-3" href="/"><span class="icon-code"></span> Developer Zone</a>
                                                                                                                                    <a class="button nav-button-2" href="https://www.mysql.com/downloads/"><span class="icon-download-thin"></span> Downloads</a>
                                                                                                <a class="button nav-button-1" href="https://www.mysql.com/"><span class="icon-sakila"></span> MySQL.com</a>
                                                                        <div id="l2-search-toggle">
                    <span class="icon-search"></span>
                </div>
                <div id="l2-site-icon">
                                                                                                                                                                                                    <span class="icon-books"></span>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        </div>
                <div id="l1-section-title">
                    <span id="l1-section-label">
                        <a href="/doc/">Documentation</a>
                    </span>
                </div>
                <nav>
                    

<ul id="l2-nav">
            	<li class="active"><a class="active " href="/doc/refman/en/">MySQL Server</a>
    			</li>
	        	<li class=""><a  href="/doc/index-enterprise.html">MySQL Enterprise</a>
    			</li>
	        	<li class=""><a  href="/doc/workbench/en/">Workbench</a>
    			</li>
	        	<li class=""><a  href="/doc/en/mysql-innodb-cluster-userguide.html">InnoDB Cluster</a>
    			</li>
	        	<li class=""><a  href="/doc/index-cluster.html">MySQL NDB Cluster</a>
    			</li>
	        	<li class=""><a  href="/doc/index-connectors.html">Connectors</a>
    			</li>
	        	<li class=" last"><a  href="/doc/index-other.html">More</a>
    			</li>
	                        <li class="other-section"><a href="https://www.mysql.com/">MySQL.com</a></li>
                            <li class="other-section"><a href="https://www.mysql.com/downloads/">Downloads</a></li>
                                        <li class="other-section"><a href="/">Developer Zone</a></li>
            </ul>
                </nav>
            </div>
            <div id="l3-search-container"></div>
            <div id="top-orange"><span id="section-nav">Section Menu: &nbsp; </span></div>
        </div>
    </header>
        <div id="page">
                        <div role="main" id="main">

            
                
            
<div>
    <div id="docs-sidebar-toc" class="">
    <div id="docs-toc-inner">
        <div class="docs-sidebar-header" id="docs-nav-header">
            <a class="docs-show-hide-nav" id="docs-hide-nav" href="" title="Hide Sidebar" aria-label="Hide Sidebar"><span class="icon-arrow-small-left"></span></a>
            <div class="docs-nav-links">
                                    
    <a href="cast-functions.html"
        aria-label="Previous" title="Previous: Cast Functions and Operators"><span
        class="icon-chevron-left"></span></a>
<a href="index.html" aria-label="Start" title="Start"><span class="icon-book-open"></span></a>
        <a aria-label="Up" href="functions.html" title="Up: Functions and Operators"><span class="icon-chevron-up"></span></a>
    <a href="bit-functions.html" aria-label="Next"
        title="Next: Bit Functions and Operators"><span
        class="icon-chevron-right"></span></a>
                            </div>
        </div>
                    
<div id="docs-sidebar-search-container">
    <div id="docs-sidebar-search-box">
        <form method="get" action="/mysql-manual/search-page">
            <input type="hidden" name="d" id="d" value="201" />
            <input type="hidden" name="p" id="p" value="1" />
            <input type="text" name="keyword" id="q" title="Search this Manual"
                value=""
                style="color: #bbb;"
                onfocus=""
                onblur="" />

            <button class="docs-sidebar-search-btn" aria-label="Search" title="Search" type="submit">
                <span class="icon-search"></span>
            </button>
        </form>
    </div>
</div>
                <div class="docs-sidebar-nav">
            <a class="docs-icon-home" href="/doc/"><span class="icon-home"></span>Documentation Home</a><hr />
            <div class="docs-sidebar-mtitle">MySQL 8.0 Reference Manual</div>
            <nav class="doctoc" id="doc-201">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="preface.html">Preface and Legal Notices</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="introduction.html">General Information</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="installing.html">Installing and Upgrading MySQL</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="tutorial.html">Tutorial</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="programs.html">MySQL Programs</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="server-administration.html">MySQL Server Administration</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="security.html">Security</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="backup-and-recovery.html">Backup and Recovery</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="optimization.html">Optimization</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="language-structure.html">Language Structure</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="charset.html">Character Sets, Collations, Unicode</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="data-types.html">Data Types</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-down"></span></a></div><div class="docs-sidebar-nav-link"><a href="functions.html">Functions and Operators</a></div></div>                        <div class="docs-submenu">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="func-op-summary-ref.html">Function and Operator Reference</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="type-conversion.html">Type Conversion in Expression Evaluation</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="non-typed-operators.html">Operators</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="operator-precedence.html">Operator Precedence</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="comparison-operators.html">Comparison Functions and Operators</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="logical-operators.html">Logical Operators</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="assignment-operators.html">Assignment Operators</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="control-flow-functions.html">Control Flow Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="string-functions.html">String Functions</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="string-comparison-functions.html">String Comparison Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="regexp.html">Regular Expressions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="string-functions-charset.html">Character Set and Collation of Function Results</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="numeric-functions.html">Numeric Functions and Operators</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="arithmetic-functions.html">Arithmetic Operators</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="mathematical-functions.html">Mathematical Functions</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="date-and-time-functions.html">Date and Time Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="mysql-calendar.html">What Calendar Is Used By MySQL?</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="fulltext-search.html">Full-Text Search Functions</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="fulltext-natural-language.html">Natural Language Full-Text Searches</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="fulltext-boolean.html">Boolean Full-Text Searches</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="fulltext-query-expansion.html">Full-Text Searches with Query Expansion</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="fulltext-stopwords.html">Full-Text Stopwords</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="fulltext-restrictions.html">Full-Text Restrictions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="fulltext-fine-tuning.html">Fine-Tuning MySQL Full-Text Search</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="full-text-adding-collation.html">Adding a Collation for Full-Text Indexing</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="fulltext-search-ngram.html">ngram Full-Text Parser</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="fulltext-search-mecab.html">MeCab Full-Text Parser Plugin</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="cast-functions.html">Cast Functions and Operators</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link current"><a href="xml-functions.html">XML Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="bit-functions.html">Bit Functions and Operators</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="encryption-functions.html">Encryption and Compression Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="locking-functions.html">Locking Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="information-functions.html">Information Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="spatial-analysis-functions.html">Spatial Analysis Functions</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="spatial-function-reference.html">Spatial Function Reference</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="spatial-function-argument-handling.html">Argument Handling by Spatial Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="gis-wkt-functions.html">Functions That Create Geometry Values from WKT Values</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="gis-wkb-functions.html">Functions That Create Geometry Values from WKB Values</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="gis-mysql-specific-functions.html">MySQL-Specific Functions That Create Geometry Values</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="gis-format-conversion-functions.html">Geometry Format Conversion Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="gis-property-functions.html">Geometry Property Functions</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="gis-general-property-functions.html">General Geometry Property Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="gis-point-property-functions.html">Point Property Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="gis-linestring-property-functions.html">LineString and MultiLineString Property Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="gis-polygon-property-functions.html">Polygon and MultiPolygon Property Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="gis-geometrycollection-property-functions.html">GeometryCollection Property Functions</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="spatial-operator-functions.html">Spatial Operator Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="spatial-relation-functions.html">Functions That Test Spatial Relations Between Geometry Objects</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="spatial-relation-functions-object-shapes.html">Spatial Relation Functions That Use Object Shapes</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="spatial-relation-functions-mbr.html">Spatial Relation Functions That Use Minimum Bounding Rectangles</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="spatial-geohash-functions.html">Spatial Geohash Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="spatial-geojson-functions.html">Spatial GeoJSON Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="spatial-convenience-functions.html">Spatial Convenience Functions</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="json-functions.html">JSON Functions</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="json-function-reference.html">JSON Function Reference</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="json-creation-functions.html">Functions That Create JSON Values</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="json-search-functions.html">Functions That Search JSON Values</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="json-modification-functions.html">Functions That Modify JSON Values</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="json-attribute-functions.html">Functions That Return JSON Value Attributes</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="json-table-functions.html">JSON Table Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="json-validation-functions.html">JSON Schema Validation Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="json-utility-functions.html">JSON Utility Functions</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="gtid-functions.html">Functions Used with Global Transaction Identifiers (GTIDs)</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="enterprise-encryption.html">MySQL Enterprise Encryption Functions</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="enterprise-encryption-installation.html">MySQL Enterprise Encryption Installation</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="enterprise-encryption-usage.html">MySQL Enterprise Encryption Usage and Examples</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="enterprise-encryption-function-reference.html">MySQL Enterprise Encryption Function Reference</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="enterprise-encryption-functions.html">MySQL Enterprise Encryption Function Descriptions</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="group-by-functions-and-modifiers.html">Aggregate (GROUP BY) Functions</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="group-by-functions.html">Aggregate (GROUP BY) Function Descriptions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="group-by-modifiers.html">GROUP BY Modifiers</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="group-by-handling.html">MySQL Handling of GROUP BY</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="group-by-functional-dependence.html">Detection of Functional Dependence</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="window-functions.html">Window Functions</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="window-function-descriptions.html">Window Function Descriptions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="window-functions-usage.html">Window Function Concepts and Syntax</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="window-functions-frames.html">Window Function Frame Specification</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="window-functions-named-windows.html">Named Windows</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="window-function-restrictions.html">Window Function Restrictions</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="performance-schema-functions.html">Performance Schema Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="internal-functions.html">Internal Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="miscellaneous-functions.html">Miscellaneous Functions</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable  loaded" aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="precision-math.html">Precision Math</a></div></div>                        <div class="docs-submenu hidden">
                                    
    <ul>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="precision-math-numbers.html">Types of Numeric Values</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="precision-math-decimal-characteristics.html">DECIMAL Data Type Characteristics</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="precision-math-expressions.html">Expression Handling</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="precision-math-rounding.html">Rounding Behavior</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="precision-math-examples.html">Precision Math Examples</a></div></div>                    </li>
        </ul>
                            </div>
                    </li>
        </ul>
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="sql-syntax.html">SQL Statement Syntax</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="data-dictionary.html">MySQL Data Dictionary</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="innodb-storage-engine.html">The InnoDB Storage Engine</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="storage-engines.html">Alternative Storage Engines</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="replication.html">Replication</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="group-replication.html">Group Replication</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="mysql-shell-userguide.html">MySQL Shell</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="document-store.html">Using MySQL as a Document Store</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="mysql-innodb-cluster-userguide.html">InnoDB Cluster</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="mysql-cluster.html">MySQL NDB Cluster 8.0</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="partitioning.html">Partitioning</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="stored-objects.html">Stored Objects</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="information-schema.html">INFORMATION_SCHEMA Tables</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="performance-schema.html">MySQL Performance Schema</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="sys-schema.html">MySQL sys Schema</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="connectors-apis.html">Connectors and APIs</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="extending-mysql.html">Extending MySQL</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="mysql-enterprise.html">MySQL Enterprise Edition</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="workbench.html">MySQL Workbench</a></div></div>                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="faqs.html">MySQL 8.0 Frequently Asked Questions</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="error-handling.html">Errors, Error Codes, and Common Problems</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="restrictions.html">Restrictions and Limits</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><a class="expandable " aria-label="Subnav" href=""><span class="icon-chevron-right"></span></a></div><div class="docs-sidebar-nav-link"><a href="indexes.html">Indexes</a></div></div>                        <div class="docs-submenu hidden">
                            </div>
                    </li>
            <li>
            <div><div class="docs-sidebar-nav-icon"><span class="icon-dot"></span></div><div class="docs-sidebar-nav-link"><a href="glossary.html">MySQL Glossary</a></div></div>                    </li>
        </ul>
                            </nav>
        </div>

        
<a class="docs-sidebar-section" href=""><span class="icon-related"></span>
    <span class="text">Related Documentation</span></a>
<div class="docs-sidebar-accordian open">
    <div class="text">
        <a href="/doc/relnotes/mysql/8.0/en/">MySQL 8.0 Release Notes</a><br />
        <a href="/doc/dev/mysql-server/latest/">MySQL 8.0 Source Code Documentation</a><br />
        </div>
</div>

    <a class="docs-sidebar-section" href=""><span class="icon-download-thin"></span>
        <span class="text">
            Download
                            this Manual
                    </span>
    </a>
    <div class="docs-sidebar-accordian open">
        <div class="text">
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.pdf">PDF (US Ltr)</a>
            - 46.1Mb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.a4.pdf">PDF (A4)</a>
            - 46.1Mb<br />
                        <a href="https://downloads.mysql.com/docs/mysql-ref-manual-8.0-en-pdf-1-20190611.noarch.rpm">PDF (RPM)</a>
            - 41.5Mb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.html-chapter.tar.gz">HTML Download (TGZ)</a>
            - 10.6Mb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.html-chapter.zip">HTML Download (Zip)</a>
            - 10.6Mb<br />
                        <a href="https://downloads.mysql.com/docs/mysql-ref-manual-8.0-en-html-chapter-1-20190611.noarch.rpm">HTML Download (RPM)</a>
            - 9.1Mb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.man-gpl.tar.gz">Man Pages (TGZ)</a>
            - 220.4Kb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.man-gpl.zip">Man Pages (Zip)</a>
            - 325.8Kb<br />
                        <a href="https://downloads.mysql.com/docs/mysql-8.0.info.gz">Info (Gzip)</a>
            - 4.1Mb<br />
                        <a href="https://downloads.mysql.com/docs/mysql-8.0.info.zip">Info (Zip)</a>
            - 4.1Mb<br />
                    </div>
    </div>

<a class="docs-sidebar-section" href=""><span class="icon-book"></span>
    <span class="text">Excerpts from this Manual</span></a>
<div class="docs-sidebar-accordian">
    <div class="text">
                <a href="/doc/mysql-backup-excerpt/8.0/en/">MySQL Backup and Recovery</a><br />
                <a href="/doc/mysql-g11n-excerpt/8.0/en/">MySQL Globalization</a><br />
                <a href="/doc/mysql-infoschema-excerpt/8.0/en/">MySQL Information Schema</a><br />
                <a href="/doc/mysql-installation-excerpt/8.0/en/">MySQL Installation Guide</a><br />
                <a href="/doc/mysql-security-excerpt/8.0/en/">Security in MySQL</a><br />
                <a href="/doc/mysql-startstop-excerpt/8.0/en/">Starting and Stopping MySQL</a><br />
                <a href="/doc/mysql-linuxunix-excerpt/8.0/en/">MySQL and Linux/Unix</a><br />
                <a href="/doc/mysql-windows-excerpt/8.0/en/">MySQL and Windows</a><br />
                <a href="/doc/mysql-osx-excerpt/8.0/en/">MySQL and OS X</a><br />
                <a href="/doc/mysql-solaris-excerpt/8.0/en/">MySQL and Solaris</a><br />
                <a href="/doc/mysql-sourcebuild-excerpt/8.0/en/">Building MySQL from Source</a><br />
                <a href="/doc/mysql-reslimits-excerpt/8.0/en/">MySQL Restrictions and Limitations</a><br />
                <a href="/doc/mysql-partitioning-excerpt/8.0/en/">MySQL Partitioning</a><br />
                <a href="/doc/mysql-secure-deployment-guide/8.0/en/">MySQL Secure Deployment Guide</a><br />
                <a href="/doc/mysql-tutorial-excerpt/8.0/en/">MySQL Tutorial</a><br />
                <a href="/doc/mysql-perfschema-excerpt/8.0/en/">MySQL Performance Schema</a><br />
                <a href="/doc/mysql-replication-excerpt/8.0/en/">MySQL Replication</a><br />
                <a href="/doc/mysql-repo-excerpt/8.0/en/">Using the MySQL Yum Repository</a><br />
            </div>
</div>

        <br /><span id="wkr"><br /></span>
    </div>
    </div>

    <div id="docs-main" class="has-toc">
    <div id="docs-main-inner">

                <div class="right" id="docs-version-nav">
            <a href="" id="docs-version-nav-toggle">version 8.0
            <span class="icon-chevron-down"></span></a>
            <div id="docs-version-list">
                                                                                            <a                         href="/doc/refman/5.7/en/xml-functions.html">
                        5.7
                                            </a><br />
                                                                            <a                         href="/doc/refman/5.6/en/xml-functions.html">
                        5.6
                                            </a><br />
                                                                            <a                         href="/doc/refman/5.5/en/xml-functions.html">
                        5.5
                                            </a><br />
                                                                        <div id="docs-version-nav-lang">
                                                                                                                                                    <a                                     href="/doc/refman/5.6/ja/xml-functions.html">
                                    5.6&nbsp;
                                                                            Japanese
                                                                    </a><br />
                                                                                            </div>
                            </div>
        </div>
        
        <div id="docs-show-nav" class="left hidden" style="margin-right: 15px;">
            <a class="docs-show-hide-nav" href="" aria-label="Show Sidebar"
                title="Show Sidebar"><span class="icon-arrow-small-right"></span></a>
        </div>

                        <div id="docs-breadcrumbs">
            <a href="/doc/refman/8.0/en/">MySQL 8.0 Reference Manual</a> &nbsp;/&nbsp;
                                                        <a href="functions.html">Functions and Operators</a> &nbsp;/&nbsp;
                                                                                    XML Functions
                                    </div>
        
        <div id="docs-body">
        
<div class="section">

<div class="titlepage">
<div>
<div>
<h2 class="title"><a name="xml-functions"></a>12.11 XML Functions</h2>

</div>

</div>

</div>

<div class="table">
<a name="idm139663188963408"></a><p class="title"><b>Table 12.15 XML Functions</b></p>
<div class="table-contents">
<table frame="box" rules="all" summary="A reference that lists XML functions."><col width="40%"><col width="60%"><thead><tr><th scope="col">Name</th>
<th scope="col">Description</th>
</tr></thead><tbody><tr><td scope="row"><a class="link" href="xml-functions.html#function_extractvalue"><code class="literal">ExtractValue()</code></a></td>
<td>
      Extract a value from an XML string using XPath notation
    </td>
</tr><tr><td scope="row"><a class="link" href="xml-functions.html#function_updatexml"><code class="literal">UpdateXML()</code></a></td>
<td>
      Return replaced XML fragment
    </td>
</tr></tbody></table>
</div>

</div>
<br class="table-break"><p>
      This section discusses XML and related functionality in MySQL.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">

<div class="admon-title">
Note
</div>
<p>
        It is possible to obtain XML-formatted output from MySQL in the
        <a class="link" href="mysql.html" title="4.5.1 mysql — The MySQL Command-Line Client"><span class="command"><strong>mysql</strong></span></a> and <a class="link" href="mysqldump.html" title="4.5.4 mysqldump — A Database Backup Program"><span class="command"><strong>mysqldump</strong></span></a>
        clients by invoking them with the
        <a class="link" href="mysql-command-options.html#option_mysql_xml"><code class="option">--xml</code></a> option. See
        <a class="xref" href="mysql.html" title="4.5.1 mysql — The MySQL Command-Line Client">Section 4.5.1, “<span class="command"><strong>mysql</strong></span> — The MySQL Command-Line Client”</a>, and <a class="xref" href="mysqldump.html" title="4.5.4 mysqldump — A Database Backup Program">Section 4.5.4, “<span class="command"><strong>mysqldump</strong></span> — A Database Backup Program”</a>.
</p>
</div>
<p>
      Two functions providing basic XPath 1.0 (XML Path Language,
      version 1.0) capabilities are available. Some basic information
      about XPath syntax and usage is provided later in this section;
      however, an in-depth discussion of these topics is beyond the
      scope of this manual, and you should refer to the
      <a class="ulink" href="http://www.w3.org/TR/xpath" target="_top">XML Path Language (XPath)
      1.0 standard</a> for definitive information. A useful resource
      for those new to XPath or who desire a refresher in the basics is
      the <a class="ulink" href="http://www.zvon.org/xxl/XPathTutorial/" target="_top">Zvon.org
      XPath Tutorial</a>, which is available in several languages.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">

<div class="admon-title">
Note
</div>
<p>
        These functions remain under development. We continue to improve
        these and other aspects of XML and XPath functionality in MySQL
        8.0 and onwards. You may discuss these, ask
        questions about them, and obtain help from other users with them
        in the <a class="ulink" href="https://forums.mysql.com/list.php?44" target="_top">MySQL XML User
        Forum</a>.
</p>
</div>
<p>
      XPath expressions used with these functions support user variables
      and local stored program variables. User variables are weakly
      checked; variables local to stored programs are strongly checked
      (see also Bug #26518):
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><b>User variables (weak checking). </b>
            Variables using the syntax
            <code class="literal">$@<em class="replaceable"><code>variable_name</code></em></code>
            (that is, user variables) are not checked. No warnings or
            errors are issued by the server if a variable has the wrong
            type or has previously not been assigned a value. This also
            means the user is fully responsible for any typographical
            errors, since no warnings will be given if (for example)
            <code class="literal">$@myvariable</code> is used where
            <code class="literal">$@myvariable</code> was intended.
          </p><p>
          Example:
        </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">mysql&gt; SET @xml = '&lt;a&gt;&lt;b&gt;X&lt;/b&gt;&lt;b&gt;Y&lt;/b&gt;&lt;/a&gt;';
Query OK, 0 rows affected (0.00 sec)

mysql&gt; SET @i =1, @j = 2;
Query OK, 0 rows affected (0.00 sec)

mysql&gt; SELECT @i, ExtractValue(@xml, '//b[$@i]');
+------+--------------------------------+
| @i   | ExtractValue(@xml, '//b[$@i]') |
+------+--------------------------------+
|    1 | X                              |
+------+--------------------------------+
1 row in set (0.00 sec)

mysql&gt; SELECT @j, ExtractValue(@xml, '//b[$@j]');
+------+--------------------------------+
| @j   | ExtractValue(@xml, '//b[$@j]') |
+------+--------------------------------+
|    2 | Y                              |
+------+--------------------------------+
1 row in set (0.00 sec)

mysql&gt; SELECT @k, ExtractValue(@xml, '//b[$@k]');
+------+--------------------------------+
| @k   | ExtractValue(@xml, '//b[$@k]') |
+------+--------------------------------+
| NULL |                                |
+------+--------------------------------+
1 row in set (0.00 sec)</code></pre></li><li class="listitem"><p><b>Variables in stored programs (strong checking). </b>
            Variables using the syntax
            <code class="literal">$<em class="replaceable"><code>variable_name</code></em></code>
            can be declared and used with these functions when they are
            called inside stored programs. Such variables are local to
            the stored program in which they are defined, and are
            strongly checked for type and value.
          </p><p>
          Example:
        </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">mysql&gt; DELIMITER |

mysql&gt; CREATE PROCEDURE myproc ()
    -&gt; BEGIN
    -&gt;   DECLARE i INT DEFAULT 1;
    -&gt;   DECLARE xml VARCHAR(25) DEFAULT '&lt;a&gt;X&lt;/a&gt;&lt;a&gt;Y&lt;/a&gt;&lt;a&gt;Z&lt;/a&gt;';
    -&gt;
    -&gt;   WHILE i &lt; 4 DO
    -&gt;     SELECT xml, i, ExtractValue(xml, '//a[$i]');
    -&gt;     SET i = i+1;
    -&gt;   END WHILE;
    -&gt; END |
Query OK, 0 rows affected (0.01 sec)

mysql&gt; DELIMITER ;

mysql&gt; CALL myproc();
+--------------------------+---+------------------------------+
| xml                      | i | ExtractValue(xml, '//a[$i]') |
+--------------------------+---+------------------------------+
| &lt;a&gt;X&lt;/a&gt;&lt;a&gt;Y&lt;/a&gt;&lt;a&gt;Z&lt;/a&gt; | 1 | X                            |
+--------------------------+---+------------------------------+
1 row in set (0.00 sec)

+--------------------------+---+------------------------------+
| xml                      | i | ExtractValue(xml, '//a[$i]') |
+--------------------------+---+------------------------------+
| &lt;a&gt;X&lt;/a&gt;&lt;a&gt;Y&lt;/a&gt;&lt;a&gt;Z&lt;/a&gt; | 2 | Y                            |
+--------------------------+---+------------------------------+
1 row in set (0.01 sec)

+--------------------------+---+------------------------------+
| xml                      | i | ExtractValue(xml, '//a[$i]') |
+--------------------------+---+------------------------------+
| &lt;a&gt;X&lt;/a&gt;&lt;a&gt;Y&lt;/a&gt;&lt;a&gt;Z&lt;/a&gt; | 3 | Z                            |
+--------------------------+---+------------------------------+
1 row in set (0.01 sec)</code></pre><p><b>Parameters. </b>
            Variables used in XPath expressions inside stored routines
            that are passed in as parameters are also subject to strong
            checking.
</p></li></ul>
</div>
<p>
      Expressions containing user variables or variables local to stored
      programs must otherwise (except for notation) conform to the rules
      for XPath expressions containing variables as given in the XPath
      1.0 specification.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">

<div class="admon-title">
Note
</div>
<p>
        A user variable used to store an XPath expression is treated as
        an empty string. Because of this, it is not possible to store an
        XPath expression as a user variable. (Bug #32911)
</p>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><a name="function_extractvalue"></a><p>
          <a class="indexterm" name="idm139663188908240"></a>

          <a class="link" href="xml-functions.html#function_extractvalue"><code class="literal">ExtractValue(<em class="replaceable"><code>xml_frag</code></em>,
          <em class="replaceable"><code>xpath_expr</code></em>)</code></a>
        </p><p>
          <a class="link" href="xml-functions.html#function_extractvalue"><code class="literal">ExtractValue()</code></a> takes two string
          arguments, a fragment of XML markup
          <em class="replaceable"><code>xml_frag</code></em> and an XPath expression
          <em class="replaceable"><code>xpath_expr</code></em> (also known as a
          <span class="firstterm">locator</span>); it returns the
          text (<code class="literal">CDATA</code>) of the first text node which
          is a child of the element or elements matched by the XPath
          expression.
        </p><p>
          Using this function is the equivalent of performing a match
          using the <em class="replaceable"><code>xpath_expr</code></em> after
          appending <code class="literal">/text()</code>. In other words,
          <a class="link" href="xml-functions.html#function_extractvalue"><code class="literal">ExtractValue('&lt;a&gt;&lt;b&gt;Sakila&lt;/b&gt;&lt;/a&gt;',
          '/a/b')</code></a> and
          <a class="link" href="xml-functions.html#function_extractvalue"><code class="literal">ExtractValue('&lt;a&gt;&lt;b&gt;Sakila&lt;/b&gt;&lt;/a&gt;',
          '/a/b/text()')</code></a> produce the same result.
        </p><p>
          If multiple matches are found, the content of the first child
          text node of each matching element is returned (in the order
          matched) as a single, space-delimited string.
        </p><p>
          If no matching text node is found for the expression
          (including the implicit <code class="literal">/text()</code>)—for
          whatever reason, as long as
          <em class="replaceable"><code>xpath_expr</code></em> is valid, and
          <em class="replaceable"><code>xml_frag</code></em> consists of elements which
          are properly nested and closed—an empty string is
          returned. No distinction is made between a match on an empty
          element and no match at all. This is by design.
        </p><p>
          If you need to determine whether no matching element was found
          in <em class="replaceable"><code>xml_frag</code></em> or such an element was
          found but contained no child text nodes, you should test the
          result of an expression that uses the XPath
          <code class="literal">count()</code> function. For example, both of
          these statements return an empty string, as shown here:
        </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">mysql&gt; SELECT ExtractValue('&lt;a&gt;&lt;b/&gt;&lt;/a&gt;', '/a/b');
+-------------------------------------+
| ExtractValue('&lt;a&gt;&lt;b/&gt;&lt;/a&gt;', '/a/b') |
+-------------------------------------+
|                                     |
+-------------------------------------+
1 row in set (0.00 sec)

mysql&gt; SELECT ExtractValue('&lt;a&gt;&lt;c/&gt;&lt;/a&gt;', '/a/b');
+-------------------------------------+
| ExtractValue('&lt;a&gt;&lt;c/&gt;&lt;/a&gt;', '/a/b') |
+-------------------------------------+
|                                     |
+-------------------------------------+
1 row in set (0.00 sec)</code></pre><p>
          However, you can determine whether there was actually a
          matching element using the following:
        </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">mysql&gt; SELECT ExtractValue('&lt;a&gt;&lt;b/&gt;&lt;/a&gt;', 'count(/a/b)');
+-------------------------------------+
| ExtractValue('&lt;a&gt;&lt;b/&gt;&lt;/a&gt;', 'count(/a/b)') |
+-------------------------------------+
| 1                                   |
+-------------------------------------+
1 row in set (0.00 sec)

mysql&gt; SELECT ExtractValue('&lt;a&gt;&lt;c/&gt;&lt;/a&gt;', 'count(/a/b)');
+-------------------------------------+
| ExtractValue('&lt;a&gt;&lt;c/&gt;&lt;/a&gt;', 'count(/a/b)') |
+-------------------------------------+
| 0                                   |
+-------------------------------------+
1 row in set (0.01 sec)</code></pre>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">

<div class="admon-title">
Important
</div>
<p>
            <a class="link" href="xml-functions.html#function_extractvalue"><code class="literal">ExtractValue()</code></a> returns only
            <code class="literal">CDATA</code>, and does not return any tags that
            might be contained within a matching tag, nor any of their
            content (see the result returned as <code class="literal">val1</code>
            in the following example).
</p>
</div>
<pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">mysql&gt; SELECT
    -&gt;   ExtractValue('&lt;a&gt;ccc&lt;b&gt;ddd&lt;/b&gt;&lt;/a&gt;', '/a') AS val1,
    -&gt;   ExtractValue('&lt;a&gt;ccc&lt;b&gt;ddd&lt;/b&gt;&lt;/a&gt;', '/a/b') AS val2,
    -&gt;   ExtractValue('&lt;a&gt;ccc&lt;b&gt;ddd&lt;/b&gt;&lt;/a&gt;', '//b') AS val3,
    -&gt;   ExtractValue('&lt;a&gt;ccc&lt;b&gt;ddd&lt;/b&gt;&lt;/a&gt;', '/b') AS val4,
    -&gt;   ExtractValue('&lt;a&gt;ccc&lt;b&gt;ddd&lt;/b&gt;&lt;b&gt;eee&lt;/b&gt;&lt;/a&gt;', '//b') AS val5;

+------+------+------+------+---------+
| val1 | val2 | val3 | val4 | val5    |
+------+------+------+------+---------+
| ccc  | ddd  | ddd  |      | ddd eee |
+------+------+------+------+---------+</code></pre><p>
          This function uses the current SQL collation for making
          comparisons with <code class="literal">contains()</code>, performing the
          same collation aggregation as other string functions (such as
          <a class="link" href="string-functions.html#function_concat"><code class="literal">CONCAT()</code></a>), in taking into
          account the collation coercibility of their arguments; see
          <a class="xref" href="charset-collation-coercibility.html" title="10.8.4 Collation Coercibility in Expressions">Section 10.8.4, “Collation Coercibility in Expressions”</a>, for an
          explanation of the rules governing this behavior.
        </p><p>
          (Previously, binary—that is,
          case-sensitive—comparison was always used.)
        </p><p>
          <code class="literal">NULL</code> is returned if
          <em class="replaceable"><code>xml_frag</code></em> contains elements which
          are not properly nested or closed, and a warning is generated,
          as shown in this example:
        </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">mysql&gt; SELECT ExtractValue('&lt;a&gt;c&lt;/a&gt;&lt;b', '//a');
+-----------------------------------+
| ExtractValue('&lt;a&gt;c&lt;/a&gt;&lt;b', '//a') |
+-----------------------------------+
| NULL                              |
+-----------------------------------+
1 row in set, 1 warning (0.00 sec)

mysql&gt; SHOW WARNINGS\G
*************************** 1. row ***************************
  Level: Warning
   Code: 1525
Message: Incorrect XML value: 'parse error at line 1 pos 11:
         END-OF-INPUT unexpected ('&gt;' wanted)'
1 row in set (0.00 sec)

mysql&gt; SELECT ExtractValue('&lt;a&gt;c&lt;/a&gt;&lt;b/&gt;', '//a');
+-------------------------------------+
| ExtractValue('&lt;a&gt;c&lt;/a&gt;&lt;b/&gt;', '//a') |
+-------------------------------------+
| c                                   |
+-------------------------------------+
1 row in set (0.00 sec)</code></pre></li><li class="listitem"><a name="function_updatexml"></a><p>
          <a class="indexterm" name="idm139663188859472"></a>

          <a class="link" href="xml-functions.html#function_updatexml"><code class="literal">UpdateXML(<em class="replaceable"><code>xml_target</code></em>,
          <em class="replaceable"><code>xpath_expr</code></em>,
          <em class="replaceable"><code>new_xml</code></em>)</code></a>
        </p><p>
          This function replaces a single portion of a given fragment of
          XML markup <em class="replaceable"><code>xml_target</code></em> with a new
          XML fragment <em class="replaceable"><code>new_xml</code></em>, and then
          returns the changed XML. The portion of
          <em class="replaceable"><code>xml_target</code></em> that is replaced matches
          an XPath expression <em class="replaceable"><code>xpath_expr</code></em>
          supplied by the user.
        </p><p>
          If no expression matching
          <em class="replaceable"><code>xpath_expr</code></em> is found, or if multiple
          matches are found, the function returns the original
          <em class="replaceable"><code>xml_target</code></em> XML fragment. All three
          arguments should be strings.
        </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">mysql&gt; SELECT
    -&gt;   UpdateXML('&lt;a&gt;&lt;b&gt;ccc&lt;/b&gt;&lt;d&gt;&lt;/d&gt;&lt;/a&gt;', '/a', '&lt;e&gt;fff&lt;/e&gt;') AS val1,
    -&gt;   UpdateXML('&lt;a&gt;&lt;b&gt;ccc&lt;/b&gt;&lt;d&gt;&lt;/d&gt;&lt;/a&gt;', '/b', '&lt;e&gt;fff&lt;/e&gt;') AS val2,
    -&gt;   UpdateXML('&lt;a&gt;&lt;b&gt;ccc&lt;/b&gt;&lt;d&gt;&lt;/d&gt;&lt;/a&gt;', '//b', '&lt;e&gt;fff&lt;/e&gt;') AS val3,
    -&gt;   UpdateXML('&lt;a&gt;&lt;b&gt;ccc&lt;/b&gt;&lt;d&gt;&lt;/d&gt;&lt;/a&gt;', '/a/d', '&lt;e&gt;fff&lt;/e&gt;') AS val4,
    -&gt;   UpdateXML('&lt;a&gt;&lt;d&gt;&lt;/d&gt;&lt;b&gt;ccc&lt;/b&gt;&lt;d&gt;&lt;/d&gt;&lt;/a&gt;', '/a/d', '&lt;e&gt;fff&lt;/e&gt;') AS val5
    -&gt; \G

*************************** 1. row ***************************
val1: &lt;e&gt;fff&lt;/e&gt;
val2: &lt;a&gt;&lt;b&gt;ccc&lt;/b&gt;&lt;d&gt;&lt;/d&gt;&lt;/a&gt;
val3: &lt;a&gt;&lt;e&gt;fff&lt;/e&gt;&lt;d&gt;&lt;/d&gt;&lt;/a&gt;
val4: &lt;a&gt;&lt;b&gt;ccc&lt;/b&gt;&lt;e&gt;fff&lt;/e&gt;&lt;/a&gt;
val5: &lt;a&gt;&lt;d&gt;&lt;/d&gt;&lt;b&gt;ccc&lt;/b&gt;&lt;d&gt;&lt;/d&gt;&lt;/a&gt;</code></pre></li></ul>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
        A discussion in depth of XPath syntax and usage are beyond the
        scope of this manual. Please see the
        <a class="ulink" href="http://www.w3.org/TR/xpath" target="_top">XML Path Language
        (XPath) 1.0 specification</a> for definitive information. A
        useful resource for those new to XPath or who are wishing a
        refresher in the basics is the
        <a class="ulink" href="http://www.zvon.org/xxl/XPathTutorial/" target="_top">Zvon.org
        XPath Tutorial</a>, which is available in several languages.
</p>
</div>
<p>
      Descriptions and examples of some basic XPath expressions follow:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
          <code class="literal">/<em class="replaceable"><code>tag</code></em></code>
        </p><p>
          Matches
          <code class="literal">&lt;<em class="replaceable"><code>tag</code></em>/&gt;</code> if
          and only if
          <code class="literal">&lt;<em class="replaceable"><code>tag</code></em>/&gt;</code> is
          the root element.
        </p><p>
          Example: <code class="literal">/a</code> has a match in
          <code class="literal">&lt;a&gt;&lt;b/&gt;&lt;/a&gt;</code> because it
          matches the outermost (root) tag. It does not match the inner
          <em class="replaceable"><code>a</code></em> element in
          <code class="literal">&lt;b&gt;&lt;a/&gt;&lt;/b&gt;</code> because in
          this instance it is the child of another element.
        </p></li><li class="listitem"><p>
          <code class="literal">/<em class="replaceable"><code>tag1</code></em>/<em class="replaceable"><code>tag2</code></em></code>
        </p><p>
          Matches
          <code class="literal">&lt;<em class="replaceable"><code>tag2</code></em>/&gt;</code> if
          and only if it is a child of
          <code class="literal">&lt;<em class="replaceable"><code>tag1</code></em>/&gt;</code>,
          and
          <code class="literal">&lt;<em class="replaceable"><code>tag1</code></em>/&gt;</code> is
          the root element.
        </p><p>
          Example: <code class="literal">/a/b</code> matches the
          <em class="replaceable"><code>b</code></em> element in the XML fragment
          <code class="literal">&lt;a&gt;&lt;b/&gt;&lt;/a&gt;</code> because it is
          a child of the root element <em class="replaceable"><code>a</code></em>. It
          does not have a match in
          <code class="literal">&lt;b&gt;&lt;a/&gt;&lt;/b&gt;</code> because in
          this case, <em class="replaceable"><code>b</code></em> is the root element
          (and hence the child of no other element). Nor does the XPath
          expression have a match in
          <code class="literal">&lt;a&gt;&lt;c&gt;&lt;b/&gt;&lt;/c&gt;&lt;/a&gt;</code>;
          here, <em class="replaceable"><code>b</code></em> is a descendant of
          <em class="replaceable"><code>a</code></em>, but not actually a child of
          <em class="replaceable"><code>a</code></em>.
        </p><p>
          This construct is extendable to three or more elements. For
          example, the XPath expression <code class="literal">/a/b/c</code>
          matches the <em class="replaceable"><code>c</code></em> element in the
          fragment
          <code class="literal">&lt;a&gt;&lt;b&gt;&lt;c/&gt;&lt;/b&gt;&lt;/a&gt;</code>.
        </p></li><li class="listitem"><p>
          <code class="literal">//<em class="replaceable"><code>tag</code></em></code>
        </p><p>
          Matches any instance of
          <code class="literal">&lt;<em class="replaceable"><code>tag</code></em>&gt;</code>.
        </p><p>
          Example: <code class="literal">//a</code> matches the
          <em class="replaceable"><code>a</code></em> element in any of the following:
          <code class="literal">&lt;a&gt;&lt;b&gt;&lt;c/&gt;&lt;/b&gt;&lt;/a&gt;</code>;
          <code class="literal">&lt;c&gt;&lt;a&gt;&lt;b/&gt;&lt;/a&gt;&lt;/b&gt;</code>;
          <code class="literal">&lt;c&gt;&lt;b&gt;&lt;a/&gt;&lt;/b&gt;&lt;/c&gt;</code>.
        </p><p>
          <code class="literal">//</code> can be combined with
          <code class="literal">/</code>. For example, <code class="literal">//a/b</code>
          matches the <em class="replaceable"><code>b</code></em> element in either of
          the fragments <code class="literal">&lt;a&gt;&lt;b/&gt;&lt;/a&gt;</code>
          or
          <code class="literal">&lt;c&gt;&lt;a&gt;&lt;b/&gt;&lt;/a&gt;&lt;/c&gt;</code>.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">

<div class="admon-title">
Note
</div>
<p>
            <code class="literal">//<em class="replaceable"><code>tag</code></em></code> is the
            equivalent of
            <code class="literal">/descendant-or-self::*/<em class="replaceable"><code>tag</code></em></code>.
            A common error is to confuse this with
            <code class="literal">/descendant-or-self::<em class="replaceable"><code>tag</code></em></code>,
            although the latter expression can actually lead to very
            different results, as can be seen here:
          </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">mysql&gt; SET @xml = '&lt;a&gt;&lt;b&gt;&lt;c&gt;w&lt;/c&gt;&lt;b&gt;x&lt;/b&gt;&lt;d&gt;y&lt;/d&gt;z&lt;/b&gt;&lt;/a&gt;';
Query OK, 0 rows affected (0.00 sec)

mysql&gt; SELECT @xml;
+-----------------------------------------+
| @xml                                    |
+-----------------------------------------+
| &lt;a&gt;&lt;b&gt;&lt;c&gt;w&lt;/c&gt;&lt;b&gt;x&lt;/b&gt;&lt;d&gt;y&lt;/d&gt;z&lt;/b&gt;&lt;/a&gt; |
+-----------------------------------------+
1 row in set (0.00 sec)

mysql&gt; SELECT ExtractValue(@xml, '//b[1]');
+------------------------------+
| ExtractValue(@xml, '//b[1]') |
+------------------------------+
| x z                          |
+------------------------------+
1 row in set (0.00 sec)

mysql&gt; SELECT ExtractValue(@xml, '//b[2]');
+------------------------------+
| ExtractValue(@xml, '//b[2]') |
+------------------------------+
|                              |
+------------------------------+
1 row in set (0.01 sec)

mysql&gt; SELECT ExtractValue(@xml, '/descendant-or-self::*/b[1]');
+---------------------------------------------------+
| ExtractValue(@xml, '/descendant-or-self::*/b[1]') |
+---------------------------------------------------+
| x z                                               |
+---------------------------------------------------+
1 row in set (0.06 sec)

mysql&gt; SELECT ExtractValue(@xml, '/descendant-or-self::*/b[2]');
+---------------------------------------------------+
| ExtractValue(@xml, '/descendant-or-self::*/b[2]') |
+---------------------------------------------------+
|                                                   |
+---------------------------------------------------+
1 row in set (0.00 sec)


mysql&gt; SELECT ExtractValue(@xml, '/descendant-or-self::b[1]');
+-------------------------------------------------+
| ExtractValue(@xml, '/descendant-or-self::b[1]') |
+-------------------------------------------------+
| z                                               |
+-------------------------------------------------+
1 row in set (0.00 sec)

mysql&gt; SELECT ExtractValue(@xml, '/descendant-or-self::b[2]');
+-------------------------------------------------+
| ExtractValue(@xml, '/descendant-or-self::b[2]') |
+-------------------------------------------------+
| x                                               |
+-------------------------------------------------+
1 row in set (0.00 sec)</code></pre>
</div>
</li><li class="listitem"><p>
          The <code class="literal">*</code> operator acts as a
          <span class="quote">“<span class="quote">wildcard</span>”</span> that matches any element. For example,
          the expression <code class="literal">/*/b</code> matches the
          <em class="replaceable"><code>b</code></em> element in either of the XML
          fragments <code class="literal">&lt;a&gt;&lt;b/&gt;&lt;/a&gt;</code> or
          <code class="literal">&lt;c&gt;&lt;b/&gt;&lt;/c&gt;</code>. However, the
          expression does not produce a match in the fragment
          <code class="literal">&lt;b&gt;&lt;a/&gt;&lt;/b&gt;</code> because
          <em class="replaceable"><code>b</code></em> must be a child of some other
          element. The wildcard may be used in any position: The
          expression <code class="literal">/*/b/*</code> will match any child of a
          <em class="replaceable"><code>b</code></em> element that is itself not the
          root element.
        </p></li><li class="listitem"><p>
          You can match any of several locators using the
          <code class="literal">|</code> (<a class="link" href="union.html" title="13.2.10.3 UNION Syntax"><code class="literal">UNION</code></a>)
          operator. For example, the expression
          <code class="literal">//b|//c</code> matches all
          <em class="replaceable"><code>b</code></em> and <em class="replaceable"><code>c</code></em>
          elements in the XML target.
        </p></li><li class="listitem"><p>
          It is also possible to match an element based on the value of
          one or more of its attributes. This done using the syntax
          <code class="literal"><em class="replaceable"><code>tag</code></em>[@<em class="replaceable"><code>attribute</code></em>="<em class="replaceable"><code>value</code></em>"]</code>.
          For example, the expression <code class="literal">//b[@id="idB"]</code>
          matches the second <em class="replaceable"><code>b</code></em> element in the
          fragment <code class="literal">&lt;a&gt;&lt;b id="idA"/&gt;&lt;c/&gt;&lt;b
          id="idB"/&gt;&lt;/a&gt;</code>. To match against
          <span class="emphasis"><em>any</em></span> element having
          <code class="literal"><em class="replaceable"><code>attribute</code></em>="<em class="replaceable"><code>value</code></em>"</code>,
          use the XPath expression
          <code class="literal">//*[<em class="replaceable"><code>attribute</code></em>="<em class="replaceable"><code>value</code></em>"]</code>.
        </p><p>
          To filter multiple attribute values, simply use multiple
          attribute-comparison clauses in succession. For example, the
          expression <code class="literal">//b[@c="x"][@d="y"]</code> matches the
          element <code class="literal">&lt;b c="x" d="y"/&gt;</code> occurring
          anywhere in a given XML fragment.
        </p><p>
          To find elements for which the same attribute matches any of
          several values, you can use multiple locators joined by the
          <code class="literal">|</code> operator. For example, to match all
          <em class="replaceable"><code>b</code></em> elements whose
          <em class="replaceable"><code>c</code></em> attributes have either of the
          values 23 or 17, use the expression
          <code class="literal">//b[@c="23"]|//b[@c="17"]</code>. You can also use
          the logical <code class="literal">or</code> operator for this purpose:
          <code class="literal">//b[@c="23" or @c="17"]</code>.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">

<div class="admon-title">
Note
</div>
<p>
            The difference between <code class="literal">or</code> and
            <code class="literal">|</code> is that <code class="literal">or</code> joins
            conditions, while <code class="literal">|</code> joins result sets.
</p>
</div>
</li></ul>
</div>
<p><b>XPath Limitations. </b>
        The XPath syntax supported by these functions is currently
        subject to the following limitations:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
          Nodeset-to-nodeset comparison (such as
          <code class="literal">'/a/b[@c=@d]'</code>) is not supported.
        </p></li><li class="listitem"><p>
          All of the standard XPath comparison operators are supported.
          (Bug #22823)
        </p></li><li class="listitem"><p>
          Relative locator expressions are resolved in the context of
          the root node. For example, consider the following query and
          result:
        </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">mysql&gt; SELECT ExtractValue(
    -&gt;   '&lt;a&gt;&lt;b c="1"&gt;X&lt;/b&gt;&lt;b c="2"&gt;Y&lt;/b&gt;&lt;/a&gt;',
    -&gt;    'a/b'
    -&gt; ) AS result;
+--------+
| result |
+--------+
| X Y    |
+--------+
1 row in set (0.03 sec)</code></pre><p>
          In this case, the locator <code class="literal">a/b</code> resolves to
          <code class="literal">/a/b</code>.
        </p><p>
          Relative locators are also supported within predicates. In the
          following example, <code class="literal">d[../@c="1"]</code> is resolved
          as <code class="literal">/a/b[@c="1"]/d</code>:
        </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">mysql&gt; SELECT ExtractValue(
    -&gt;      '&lt;a&gt;
    -&gt;        &lt;b c="1"&gt;&lt;d&gt;X&lt;/d&gt;&lt;/b&gt;
    -&gt;        &lt;b c="2"&gt;&lt;d&gt;X&lt;/d&gt;&lt;/b&gt;
    -&gt;      &lt;/a&gt;',
    -&gt;      'a/b/d[../@c="1"]')
    -&gt; AS result;
+--------+
| result |
+--------+
| X      |
+--------+
1 row in set (0.00 sec)</code></pre></li><li class="listitem"><p>
          Locators prefixed with expressions that evaluate as scalar
          values—including variable references, literals, numbers,
          and scalar function calls—are not permitted, and their
          use results in an error.
        </p></li><li class="listitem"><p>
          The <code class="literal">::</code> operator is not supported in
          combination with node types such as the following:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p>
              <code class="literal"><em class="replaceable"><code>axis</code></em>::comment()</code>
            </p></li><li class="listitem"><p>
              <code class="literal"><em class="replaceable"><code>axis</code></em>::text()</code>
            </p></li><li class="listitem"><p>
              <code class="literal"><em class="replaceable"><code>axis</code></em>::processing-instructions()</code>
            </p></li><li class="listitem"><p>
              <code class="literal"><em class="replaceable"><code>axis</code></em>::node()</code>
</p></li></ul>
</div>
<p>
          However, name tests (such as
          <code class="literal"><em class="replaceable"><code>axis</code></em>::<em class="replaceable"><code>name</code></em></code>
          and <code class="literal"><em class="replaceable"><code>axis</code></em>::*</code>) are
          supported, as shown in these examples:
        </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">mysql&gt; SELECT ExtractValue('&lt;a&gt;&lt;b&gt;x&lt;/b&gt;&lt;c&gt;y&lt;/c&gt;&lt;/a&gt;','/a/child::b');
+-------------------------------------------------------+
| ExtractValue('&lt;a&gt;&lt;b&gt;x&lt;/b&gt;&lt;c&gt;y&lt;/c&gt;&lt;/a&gt;','/a/child::b') |
+-------------------------------------------------------+
| x                                                     |
+-------------------------------------------------------+
1 row in set (0.02 sec)

mysql&gt; SELECT ExtractValue('&lt;a&gt;&lt;b&gt;x&lt;/b&gt;&lt;c&gt;y&lt;/c&gt;&lt;/a&gt;','/a/child::*');
+-------------------------------------------------------+
| ExtractValue('&lt;a&gt;&lt;b&gt;x&lt;/b&gt;&lt;c&gt;y&lt;/c&gt;&lt;/a&gt;','/a/child::*') |
+-------------------------------------------------------+
| x y                                                   |
+-------------------------------------------------------+
1 row in set (0.01 sec)</code></pre></li><li class="listitem"><p>
          <span class="quote">“<span class="quote">Up-and-down</span>”</span> navigation is not supported in
          cases where the path would lead <span class="quote">“<span class="quote">above</span>”</span> the root
          element. That is, you cannot use expressions which match on
          descendants of ancestors of a given element, where one or more
          of the ancestors of the current element is also an ancestor of
          the root element (see Bug #16321).
        </p></li><li class="listitem"><p>
          The following XPath functions are not supported, or have known
          issues as indicated:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p>
              <code class="literal">id()</code>
            </p></li><li class="listitem"><p>
              <code class="literal">lang()</code>
            </p></li><li class="listitem"><p>
              <code class="literal">local-name()</code>
            </p></li><li class="listitem"><p>
              <code class="literal">name()</code>
            </p></li><li class="listitem"><p>
              <code class="literal">namespace-uri()</code>
            </p></li><li class="listitem"><p>
              <code class="literal">normalize-space()</code>
            </p></li><li class="listitem"><p>
              <code class="literal">starts-with()</code>
            </p></li><li class="listitem"><p>
              <code class="literal">string()</code>
            </p></li><li class="listitem"><p>
              <code class="literal">substring-after()</code>
            </p></li><li class="listitem"><p>
              <code class="literal">substring-before()</code>
            </p></li><li class="listitem"><p>
              <code class="literal">translate()</code>
</p></li></ul>
</div>
</li><li class="listitem"><p>
          The following axes are not supported:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p>
              <code class="literal">following-sibling</code>
            </p></li><li class="listitem"><p>
              <code class="literal">following</code>
            </p></li><li class="listitem"><p>
              <code class="literal">preceding-sibling</code>
            </p></li><li class="listitem"><p>
              <code class="literal">preceding</code>
</p></li></ul>
</div>
</li></ul>
</div>
<p>
      XPath expressions passed as arguments to
      <a class="link" href="xml-functions.html#function_extractvalue"><code class="literal">ExtractValue()</code></a> and
      <a class="link" href="xml-functions.html#function_updatexml"><code class="literal">UpdateXML()</code></a> may contain the colon
      character (<code class="literal">:</code>) in element selectors, which
      enables their use with markup employing XML namespaces notation.
      For example:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">mysql&gt; SET @xml = '&lt;a&gt;111&lt;b:c&gt;222&lt;d&gt;333&lt;/d&gt;&lt;e:f&gt;444&lt;/e:f&gt;&lt;/b:c&gt;&lt;/a&gt;';
Query OK, 0 rows affected (0.00 sec)

mysql&gt; SELECT ExtractValue(@xml, '//e:f');
+-----------------------------+
| ExtractValue(@xml, '//e:f') |
+-----------------------------+
| 444                         |
+-----------------------------+
1 row in set (0.00 sec)

mysql&gt; SELECT UpdateXML(@xml, '//b:c', '&lt;g:h&gt;555&lt;/g:h&gt;');
+--------------------------------------------+
| UpdateXML(@xml, '//b:c', '&lt;g:h&gt;555&lt;/g:h&gt;') |
+--------------------------------------------+
| &lt;a&gt;111&lt;g:h&gt;555&lt;/g:h&gt;&lt;/a&gt;                   |
+--------------------------------------------+
1 row in set (0.00 sec)</code></pre><p>
      This is similar in some respects to what is permitted by
      <a class="ulink" href="http://xalan.apache.org/" target="_top">Apache Xalan</a> and
      some other parsers, and is much simpler than requiring namespace
      declarations or the use of the <code class="literal">namespace-uri()</code>
      and <code class="literal">local-name()</code> functions.
    </p><p><b>Error handling. </b>
        For both <a class="link" href="xml-functions.html#function_extractvalue"><code class="literal">ExtractValue()</code></a> and
        <a class="link" href="xml-functions.html#function_updatexml"><code class="literal">UpdateXML()</code></a>, the XPath locator
        used must be valid and the XML to be searched must consist of
        elements which are properly nested and closed. If the locator is
        invalid, an error is generated:
      </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">mysql&gt; SELECT ExtractValue('&lt;a&gt;c&lt;/a&gt;&lt;b/&gt;', '/&amp;a');
ERROR 1105 (HY000): XPATH syntax error: '&amp;a'</code></pre><p>
      If <em class="replaceable"><code>xml_frag</code></em> does not consist of
      elements which are properly nested and closed,
      <code class="literal">NULL</code> is returned and a warning is generated, as
      shown in this example:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">mysql&gt; SELECT ExtractValue('&lt;a&gt;c&lt;/a&gt;&lt;b', '//a');
+-----------------------------------+
| ExtractValue('&lt;a&gt;c&lt;/a&gt;&lt;b', '//a') |
+-----------------------------------+
| NULL                              |
+-----------------------------------+
1 row in set, 1 warning (0.00 sec)

mysql&gt; SHOW WARNINGS\G
*************************** 1. row ***************************
  Level: Warning
   Code: 1525
Message: Incorrect XML value: 'parse error at line 1 pos 11:
         END-OF-INPUT unexpected ('&gt;' wanted)'
1 row in set (0.00 sec)

mysql&gt; SELECT ExtractValue('&lt;a&gt;c&lt;/a&gt;&lt;b/&gt;', '//a');
+-------------------------------------+
| ExtractValue('&lt;a&gt;c&lt;/a&gt;&lt;b/&gt;', '//a') |
+-------------------------------------+
| c                                   |
+-------------------------------------+
1 row in set (0.00 sec)</code></pre>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">

<div class="admon-title">
Important
</div>
<p>
        The replacement XML used as the third argument to
        <a class="link" href="xml-functions.html#function_updatexml"><code class="literal">UpdateXML()</code></a> is
        <span class="emphasis"><em>not</em></span> checked to determine whether it
        consists solely of elements which are properly nested and
        closed.
</p>
</div>
<p><b>XPath Injection. </b>
        <span class="firstterm">code injection</span> occurs when
        malicious code is introduced into the system to gain
        unauthorized access to privileges and data. It is based on
        exploiting assumptions made by developers about the type and
        content of data input from users. XPath is no exception in this
        regard.
      </p><p>
      A common scenario in which this can happen is the case of
      application which handles authorization by matching the
      combination of a login name and password with those found in an
      XML file, using an XPath expression like this one:
    </p><pre class="programlisting copytoclipboard line-numbers language-simple one-line"><code class="language-simple">//user[login/text()='neapolitan' and password/text()='1c3cr34m']/attribute::id</code></pre><p>
      This is the XPath equivalent of an SQL statement like this one:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql one-line"><code class="language-sql">SELECT id FROM users WHERE login='neapolitan' AND password='1c3cr34m';</code></pre><p>
      A PHP application employing XPath might handle the login process
      like this:
    </p><pre class="programlisting copytoclipboard line-numbers language-php"><code class="language-php">&lt;?php

  $file     =   "users.xml";

  $login    =   $POST["login"];
  $password =   $POST["password"];

  $xpath = "//user[login/text()=$login and password/text()=$password]/attribute::id";

  if( file_exists($file) )
  {
    $xml = simplexml_load_file($file);

    if($result = $xml-&gt;xpath($xpath))
      echo "You are now logged in as user $result[0].";
    else
      echo "Invalid login name or password.";
  }
  else
    exit("Failed to open $file.");

?&gt;</code></pre><p>
      No checks are performed on the input. This means that a malevolent
      user can <span class="quote">“<span class="quote">short-circuit</span>”</span> the test by entering
      <code class="literal">' or 1=1</code> for both the login name and password,
      resulting in <code class="varname">$xpath</code> being evaluated as shown
      here:
    </p><pre class="programlisting copytoclipboard line-numbers language-simple one-line"><code class="language-simple">//user[login/text()='' or 1=1 and password/text()='' or 1=1]/attribute::id</code></pre><p>
      Since the expression inside the square brackets always evaluates
      as <code class="literal">true</code>, it is effectively the same as this
      one, which matches the <code class="literal">id</code> attribute of every
      <code class="literal">user</code> element in the XML document:
    </p><pre class="programlisting copytoclipboard line-numbers language-simple one-line"><code class="language-simple">//user/attribute::id</code></pre><p>
      One way in which this particular attack can be circumvented is
      simply by quoting the variable names to be interpolated in the
      definition of <code class="literal">$xpath</code>, forcing the values passed
      from a Web form to be converted to strings:
    </p><pre class="programlisting copytoclipboard line-numbers language-simple one-line"><code class="language-simple">$xpath = "//user[login/text()='$login' and password/text()='$password']/attribute::id";</code></pre><p>
      This is the same strategy that is often recommended for preventing
      SQL injection attacks. In general, the practices you should follow
      for preventing XPath injection attacks are the same as for
      preventing SQL injection:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
          Never accepted untested data from users in your application.
        </p></li><li class="listitem"><p>
          Check all user-submitted data for type; reject or convert data
          that is of the wrong type
        </p></li><li class="listitem"><p>
          Test numeric data for out of range values; truncate, round, or
          reject values that are out of range. Test strings for illegal
          characters and either strip them out or reject input
          containing them.
        </p></li><li class="listitem"><p>
          Do not output explicit error messages that might provide an
          unauthorized user with clues that could be used to compromise
          the system; log these to a file or database table instead.
</p></li></ul>
</div>
<p>
      Just as SQL injection attacks can be used to obtain information
      about database schemas, so can XPath injection be used to traverse
      XML files to uncover their structure, as discussed in Amit
      Klein's paper
      <a class="ulink" href="http://www.packetstormsecurity.org/papers/bypass/Blind_XPath_Injection_20040518.pdf" target="_top">Blind
      XPath Injection</a> (PDF file, 46KB).
    </p><p>
      It is also important to check the output being sent back to the
      client. Consider what can happen when we use the MySQL
      <a class="link" href="xml-functions.html#function_extractvalue"><code class="literal">ExtractValue()</code></a> function:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">mysql&gt; SELECT ExtractValue(
    -&gt;     LOAD_FILE('users.xml'),
    -&gt;     '//user[login/text()="" or 1=1 and password/text()="" or 1=1]/attribute::id'
    -&gt; ) AS id;
+-------------------------------+
| id                            |
+-------------------------------+
| 00327 13579 02403 42354 28570 |
+-------------------------------+
1 row in set (0.01 sec)</code></pre><p>
      Because <a class="link" href="xml-functions.html#function_extractvalue"><code class="literal">ExtractValue()</code></a> returns
      multiple matches as a single space-delimited string, this
      injection attack provides every valid ID contained within
      <code class="filename">users.xml</code> to the user as a single row of
      output. As an extra safeguard, you should also test output before
      returning it to the user. Here is a simple example:
    </p><pre class="programlisting copytoclipboard line-numbers language-sql"><code class="language-sql">mysql&gt; SELECT @id = ExtractValue(
    -&gt;     LOAD_FILE('users.xml'),
    -&gt;     '//user[login/text()="" or 1=1 and password/text()="" or 1=1]/attribute::id'
    -&gt; );
Query OK, 0 rows affected (0.00 sec)

mysql&gt; SELECT IF(
    -&gt;     INSTR(@id, ' ') = 0,
    -&gt;     @id,
    -&gt;     'Unable to retrieve user ID')
    -&gt; AS singleID;
+----------------------------+
| singleID                   |
+----------------------------+
| Unable to retrieve user ID |
+----------------------------+
1 row in set (0.00 sec)</code></pre><p>
      In general, the guidelines for returning data to users securely
      are the same as for accepting user input. These can be summed up
      as:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
          Always test outgoing data for type and permissible values.
        </p></li><li class="listitem"><p>
          Never permit unauthorized users to view error messages that
          might provide information about the application that could be
          used to exploit it.
</p></li></ul>
</div>

</div>

<br />
        </div>

                <div id="docs-in-page-nav-container">
            <div id="docs-in-page-nav">
                
    <a href="cast-functions.html"
        aria-label="Previous" title="Previous: Cast Functions and Operators"><span
        class="icon-chevron-left"></span> PREV</a> &nbsp;
<a href="index.html" aria-label="Start" title="Start"> HOME</a> &nbsp;
        <a aria-label="Up" href="functions.html" title="Up: Functions and Operators"> UP</a> &nbsp;
    <a href="bit-functions.html" aria-label="Next"
        title="Next: Bit Functions and Operators">NEXT <span
        class="icon-chevron-right"></span></a>
            </div>
        </div>
        
         <div id="docs-body-extra">
             
<a class="docs-sidebar-section" href=""><span class="icon-related"></span>
    <span class="text">Related Documentation</span></a>
<div class="docs-sidebar-accordian">
    <div class="text">
        <a href="/doc/relnotes/mysql/8.0/en/">MySQL 8.0 Release Notes</a><br />
        <a href="/doc/dev/mysql-server/latest/">MySQL 8.0 Source Code Documentation</a><br />
        </div>
</div>

    <a class="docs-sidebar-section" href=""><span class="icon-download-thin"></span>
        <span class="text">
            Download
                            this Manual
                    </span>
    </a>
    <div class="docs-sidebar-accordian">
        <div class="text">
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.pdf">PDF (US Ltr)</a>
            - 46.1Mb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.a4.pdf">PDF (A4)</a>
            - 46.1Mb<br />
                        <a href="https://downloads.mysql.com/docs/mysql-ref-manual-8.0-en-pdf-1-20190611.noarch.rpm">PDF (RPM)</a>
            - 41.5Mb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.html-chapter.tar.gz">HTML Download (TGZ)</a>
            - 10.6Mb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.html-chapter.zip">HTML Download (Zip)</a>
            - 10.6Mb<br />
                        <a href="https://downloads.mysql.com/docs/mysql-ref-manual-8.0-en-html-chapter-1-20190611.noarch.rpm">HTML Download (RPM)</a>
            - 9.1Mb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.man-gpl.tar.gz">Man Pages (TGZ)</a>
            - 220.4Kb<br />
                        <a href="https://downloads.mysql.com/docs/refman-8.0-en.man-gpl.zip">Man Pages (Zip)</a>
            - 325.8Kb<br />
                        <a href="https://downloads.mysql.com/docs/mysql-8.0.info.gz">Info (Gzip)</a>
            - 4.1Mb<br />
                        <a href="https://downloads.mysql.com/docs/mysql-8.0.info.zip">Info (Zip)</a>
            - 4.1Mb<br />
                    </div>
    </div>

<a class="docs-sidebar-section" href=""><span class="icon-book"></span>
    <span class="text">Excerpts from this Manual</span></a>
<div class="docs-sidebar-accordian">
    <div class="text">
                <a href="/doc/mysql-backup-excerpt/8.0/en/">MySQL Backup and Recovery</a><br />
                <a href="/doc/mysql-g11n-excerpt/8.0/en/">MySQL Globalization</a><br />
                <a href="/doc/mysql-infoschema-excerpt/8.0/en/">MySQL Information Schema</a><br />
                <a href="/doc/mysql-installation-excerpt/8.0/en/">MySQL Installation Guide</a><br />
                <a href="/doc/mysql-security-excerpt/8.0/en/">Security in MySQL</a><br />
                <a href="/doc/mysql-startstop-excerpt/8.0/en/">Starting and Stopping MySQL</a><br />
                <a href="/doc/mysql-linuxunix-excerpt/8.0/en/">MySQL and Linux/Unix</a><br />
                <a href="/doc/mysql-windows-excerpt/8.0/en/">MySQL and Windows</a><br />
                <a href="/doc/mysql-osx-excerpt/8.0/en/">MySQL and OS X</a><br />
                <a href="/doc/mysql-solaris-excerpt/8.0/en/">MySQL and Solaris</a><br />
                <a href="/doc/mysql-sourcebuild-excerpt/8.0/en/">Building MySQL from Source</a><br />
                <a href="/doc/mysql-reslimits-excerpt/8.0/en/">MySQL Restrictions and Limitations</a><br />
                <a href="/doc/mysql-partitioning-excerpt/8.0/en/">MySQL Partitioning</a><br />
                <a href="/doc/mysql-secure-deployment-guide/8.0/en/">MySQL Secure Deployment Guide</a><br />
                <a href="/doc/mysql-tutorial-excerpt/8.0/en/">MySQL Tutorial</a><br />
                <a href="/doc/mysql-perfschema-excerpt/8.0/en/">MySQL Performance Schema</a><br />
                <a href="/doc/mysql-replication-excerpt/8.0/en/">MySQL Replication</a><br />
                <a href="/doc/mysql-repo-excerpt/8.0/en/">Using the MySQL Yum Repository</a><br />
            </div>
</div>
         </div>

              </div>
     </div>

</div>

<script>
$(function() {
    var doc = new $.doc({ 'mobile': $.browser.mobile, 'docId': 1, 'highlight': true });
});
</script>
    

            
        </div>
    </div>

    <footer class="collapsed">
        <div id="footer-bottom">
                                    <div id="footer-collapse">
                <a href="" id="expand-footer"
                    aria-label="Expand Footer"
                    title="Expand Footer"><span
                    class="icon-plus-square"></span></a>
            </div>
                        <div class="footer-contact">
                <div id="footer-contact-icon" style="display: none;">
                    <span class="icon-call-phone"></span>
                </div>
                <div id="footer-contact-numbers" style="display: none;">
                    <strong>Contact MySQL Sales</strong><br/>
                    USA/Canada: +1-866-221-0634 &nbsp;
                    (<a href="https://www.mysql.com/about/contact/phone/">More Countries &raquo;</a>)
                </div>
                <div id="footer-contact-copyright" style="display: inline-block;">
                    <a href="http://www.oracle.com/" aria-label="Oracle" title="Oracle"><span class="oracle-logo"></span></a>
                    &nbsp; &copy; 2019, Oracle Corporation and/or its affiliates
                </div>
            </div>
            <div class="social-icons">
                <a aria-label="Join us on Facebook" title="Join us on Facebook" href="http://www.facebook.com/mysql"><span class="icon-facebook-square"></span></a>
                <a aria-label="Follow us on Twitter" title="Follow us on Twitter" href="https://twitter.com/mysql"><span class="icon-twitter-square"></span></a>
                <a aria-label="Follow us on LinkedIn" title="Follow us on LinkedIn" href="https://www.linkedin.com/company/mysql"><span class="icon-linkedin-square"></span></a>
                <a aria-label="Visit our YouTube channel" title="Visit our YouTube channel" href="http://www.youtube.com/mysqlchannel"><span class="icon-youtube-square"></span></a>
            </div>
            <br class="clear" />
        </div>
        <div id="footer-links">

            <div id="footer-nav"></div>

            <div class="links">
                <ul>
                    <li class="top"><a href="https://www.mysql.com/products/">Products</a></li>
                    <li><a href="https://www.mysql.com/cloud/">Oracle MySQL Cloud Service</a></li>
                    <li><a href="https://www.mysql.com/products/enterprise/">MySQL Enterprise Edition</a></li>
                    <li><a href="https://www.mysql.com/products/standard/">MySQL Standard Edition</a></li>
                    <li><a href="https://www.mysql.com/products/classic/">MySQL Classic Edition</a></li>
                    <li><a href="https://www.mysql.com/products/cluster/">MySQL Cluster CGE</a></li>
                    <li><a href="https://www.mysql.com/oem/">MySQL Embedded (OEM/ISV)</a></li>
                </ul>
            </div>

            <div class="links">
                <ul>
                    <li class="top"><a href="https://www.mysql.com/services/">Services</a></li>
                    <li><a href="https://www.mysql.com/training/">Training</a></li>
                    <li><a href="https://www.mysql.com/certification/">Certification</a></li>
                    <li><a href="https://www.mysql.com/consulting/">Consulting</a></li>
                    <li><a href="https://www.mysql.com/support/">Support</a></li>
                </ul>
            </div>

            <div class="links">
                <ul>
                    <li class="top"><a href="https://dev.mysql.com/downloads/">Downloads</a></li>
                    <li><a href="https://dev.mysql.com/downloads/mysql/">MySQL Community Server</a></li>
                    <li><a href="https://dev.mysql.com/downloads/cluster/">MySQL NDB Cluster</a></li>
                    <li><a href="https://dev.mysql.com/downloads/shell/">MySQL Shell</a></li>
                    <li><a href="https://dev.mysql.com/downloads/router/">MySQL Router</a></li>
                    <li><a href="https://dev.mysql.com/downloads/workbench/">MySQL Workbench</a></li>
                </ul>
            </div>

            <div class="links">
                <ul>
                    <li class="top"><a href="https://dev.mysql.com/doc/">Documentation</a></li>
                    <li><a href="https://dev.mysql.com/doc/refman/en/">MySQL Reference Manual</a></li>
                    <li><a href="https://dev.mysql.com/doc/workbench/en/">MySQL Workbench</a></li>
                    <li><a href="https://dev.mysql.com/doc/index-cluster.html">MySQL NDB Cluster</a></li>
                    <li><a href="https://dev.mysql.com/doc/index-connectors.html">MySQL Connectors</a></li>
                    <li><a href="https://dev.mysql.com/doc/#topic">Topic Guides</a></li>
                </ul>
            </div>

            <div class="links">
                <ul>
                    <li class="top"><a href="https://www.mysql.com/about/">About MySQL</a></li>
                    <li><a href="https://www.mysql.com/about/contact/">Contact Us</a></li>
                                                            <li><a href="https://www.mysql.com/buy-mysql/">How to Buy</a></li>
                    <li><a href="https://www.mysql.com/partners/">Partners</a></li>
                    <li><a href="https://www.mysql.com/about/jobs/">Job Opportunities</a></li>
                    <li><a href="https://www.mysql.com/sitemap.html">Site Map</a></li>
                </ul>
            </div>

            
            <div id="footer-logo">
                <a href="http://www.oracle.com/" aria-label="Oracle" title="Oracle"><span class="oracle-logo"></span></a>
                &nbsp; &copy; 2019, Oracle Corporation and/or its affiliates
                <div class="footer-legal-links">
                    <a href="https://www.mysql.com/about/legal/">Legal Policies</a> |
                    <a href="http://www.oracle.com/us/legal/privacy/index.htm">Your Privacy Rights</a> |
                    <a href="http://www.oracle.com/us/legal/terms/index.html">Terms of Use</a> |
                    <a href="http://www.oracle.com/us/legal/third-party-trademarks/index.html">Trademark Policy</a> |
                    <a href="http://www.oracle.com/technetwork/community/oca-486395.html">Contributor Agreement</a> |
                    <div id="teconsent" style="display: inline-block"><script async="async" type="text/javascript" src="js/notice.js" crossorigin=""></script></div>
                </div>
            </div>

        </div>
    </footer>
</div>

        <script src="js/s_code_remote.js"></script>

        
    
</body>
</html>
